/*
 * AjLog - The AspectJ based Logging Facade
 *
 * Copyright (C) 2009 - 2010, the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ajlog.annotations.context;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotate a parameter for adding a parameter to the AjLog context.
 * <br>
 * Caution: {@link Context} will be recognized by AjLog only if the containing <b>class</b> has been annotated with {@link ContextAware}
 * 
 * <br><br>
 * Example:<br>
 * <pre>
 * &#64;{@link ContextAware} // &lArr; Marking the class with this annotation is necessary.
 * public class MyClass {
 *      // Any method which has at least one parameter annotated with {@link Context} will be wrapped 
 *      // and all parameters will be stored within AjLog context
 *      public void loginUser(
 *              &#64;Context("user") User user
 *          ) {
 *          // all logging method below this method <code>loginUser</code> have access to the context variable <i>uc.user</i> 
 *          // (<i>uc</i> stands for <i>user context</i>)
 *      }
 * };
 * </pre>
 * @author Marko Umek
 * 
 * @see ContextAware
 *
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
@Documented
public @interface Context {
    /**
     * @return the name of the context parameter. This name will be used in the message generation or the MDC support.
     */
    String value();
}
